package com.seata.cloud.controller;

import com.seata.cloud.response.Result;
import com.seata.cloud.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author wangyabin
 * @date 2021/12/6 16:54
 */
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;
    
    /**
     * 扣减账户余额
     */
    @RequestMapping("/account/decrease/{userId}/{money}")
    public Result decrease(@PathVariable("userId") Long userId, @PathVariable("money") BigDecimal money){
        accountService.decrease(userId,money);
        return Result.success("扣款成功",200);
    }

}
